package oa.game;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

public class MySQLConnector {

    private static final Logger logger = Logger.getLogger(MySQLConnector.class.getName());
    private static boolean driver_loaded = false;
    private static final String url = "jdbc:mysql://192.168.1.210:3306/InfArenaRoR_development?noDatetimeStringSync=true&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useUnbufferedInput=false";
    private static final String userName = "infarenauser";
    private static final String password = "password";

    public synchronized static Connection getConnection() throws SQLException {

        if (!driver_loaded) {
            String driver = "com.mysql.jdbc.Driver";
            try {
                Class.forName(driver).newInstance();
                driver_loaded = true;
            } catch (Exception ex) {
                logger.log(Level.SEVERE, null, ex);
            }
        }

        return DriverManager.getConnection(url, userName, password);
    }
}
